package com.zjw.controller;

import com.alibaba.fastjson.JSON;
import com.zjw.license.*;
import com.zjw.service.LicenseService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 用于生成证书文件，不能放在给客户部署的代码里
 *
 * @author zjw
 * @date 2021/4/20 14:29
 */
@Component
@Slf4j
public class LicenseController implements CommandLineRunner {

    @Resource
    private LicenseService licenseService;

    @Override
    public void run(String... args) throws Exception {
        LicenseRes licenseRes = licenseService.generateLicense();
        if (licenseRes.getResult()) {
            log.info("证书生成成功:{}", JSON.toJSONString(licenseRes));
        }
    }
}
